import { Product } from '../../pages/product/product-model.js';
var product = new Product();
import {Center} from '../../pages/center/center-model.js';
var center = new Center();
Component({
  properties: {
    hiddenAuth: {
      type: Boolean,
      value: true
    },
  },
  data: {

  },
  ready: function () {
  },
  methods: {
    //获取用户授权信息
    bindGetUserInfo: function (e) {
      if (!e.detail.userInfo) {
        that.setData({
          hiddenAuth:true
        })
        wx.showToast({
          title: '您拒绝了授权',
          icon:'none'
        })
        return false;
      }
      var that = this;
      center._updateUserInfo(e.detail.userInfo, (data) => {
        //data.user.username = data.user.nickName;
        if (data.user.status == 0) {
          wx.redirectTo({
            url: '/pages/home/forbidden',
          })
          return false;
        }
        wx.setStorageSync('userInfo', data.user);
        if (data.user) {
          that.setData({
            userInfo: data.user,
            hiddenAuth:true
          })
          wx.showToast({
            title: '授权成功',
            icon:'none'
          })
        }
        let url = wx.getStorageSync('redirect-url');
        if (url) {
          wx.redirectTo({
            url: url,
          })
        }
      });
    },
  }
})